<?php

//
// Stone大叔💯 
// ============================================================================
// ----------------------------------------------------------------------------
// <><><><><><><><><><><><><>有妹子加微信不哦！~<><><><><><><><><><><><><><><><>
// ----------------------------------------------------------------------------
// ============================================================================
// $Author: Stone大叔💯 $
// $Z Stone大叔💯 $
//

namespace Stone\Library;

class Template {
    private $_view   =   NULL;


    public function __construct() {
        $type   =   C('TMPL_TYPE')  ? ucfirst(strtolower(C('TMPL_TYPE'))) : "SmartyTemplate";
        $class_name  =   "\\Stone\\Library\\Template\\Driver\\".$type."Template";
        if(!class_exists($class_name))
            E('View Driver non-existes');        
        $this->_view    =      new $class_name();
        
    }
    
    public function display($template = null, $cache_id = null, $compile_id = null, $parent = null)
    {
        return $this->_view->display($template, $cache_id, $compile_id, $parent);
    }
    
    public function assign($tpl_var, $value, $nocache){
        return $this->_view->assign($tpl_var, $value, $nocache);
    }
    
    public function setCaching()//开启缓存
    {
        return $this->_view->setCaching(\Smarty::CACHING_LIFETIME_SAVED);
    }
    public function append($tpl_var, $value = null, $merge = false, $nocache = false) // 把值追加到数组。
    {
        return $this->_view->append($tpl_var, $value, $merge, $nocache);
    }
    public function clearAllAssign() // 清除全部赋值
    {
        return $this->_view->clearAllAssign();
    }
    public function clearAllCache() // 清除全部缓存
    {
        return $this->_view->clearAllCache();
    }
    public function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null) // 清除缓存
    {
        return $this->_view->clearCache($template_name, $cache_id , $compile_id , $exp_time , $type );
    }
    public function clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null) // 清除模板编译文件
    {
        return $this->_view->clearCompiledTemplate($resource_name, $compile_id, $exp_time);
    }
    public function compileAllTemplates() // 编译全部模板
    {
        return $this->_view->compileAllTemplates();
    }
    public function disableSecurity() // 关闭安全检查
    {
        return $this->_view->disableSecurity();
    }
    public function enableSecurity() // 开启安全检查
    {
        return $this->_view->enableSecurity();
    }
    public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false) // 取得输出内容
    {
        return $this->_view->fetch($template, $cache_id, $compile_id, $parent, $display, $merge_tpl_vars, $no_output_filter);
    }
    public function isCached($template = null, $cache_id = null, $compile_id = null, $parent = null) // 检查模板是否已经缓存
    {
        return $this->_view->isCached($template, $cache_id, $compile_id, $parent);
    }
    public function templateExists($resource_name) // 检查模板是否存在
    {
        return $this->_view->templateExists($resource_name);
    }	

    
    
}
